#include <stdio.h>
#include <unistd.h>

/**
  * shows how the return value from fork()
  * allows a process to determine whether 
  * it is a child or process
  */

int main() {
	int fork_rv;
	printf("Before: my pid is %d\n", getpid());

	fork_rv = fork();			/* create new process */

	if (fork_rv == -1) {
		perror("fork");
	} else if (fork_rv == 0) {
		printf("I'm the child. my pid = %d\n", getpid());
	} else {
		printf("I'm the parent. my pid = %d, my child = %d\n", getpid(), fork_rv);
	}
	return 0;
}
